home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / cnet / viewlog.lha / viewlog5 / VL_AMaint < prev    next >
Text File  |  1996-11-08  |  6KB  |  132 lines

  1. /**************************************************************************\
  2.       $VER: ViewLog AMaint, v5.02 (8-Nov-96) by Dotoran of Frontiers!
  3. \**************************************************************************/
  4. options results ; signal on SYNTAX ; signal on ERROR ; signal on IOERR
  5. tr=transmit ; se=sendstring ; gc=getchar ; gu=getuser ; gs=getscratch
  6. a="rexxsupport.library";if ~show("l",a) then if ~addlib(a,0,-30) then exit
  7. ver="5.02" ; changewhere "ViewLog5 AMaint" ; zy=0
  8.  
  9. BEGIN: ; call READCONFIG ; call CHECKVER ; call READDATA
  10. call DELETE("sysdata:log/ViewLog5")
  11. call LOG("[*] View Log, v"ver" AutoMaintenance started...")
  12.  
  13. /* Check for NEW logs */
  14.  
  15. a=showdir("SysData:Log/","F");se "n1Checking for new logs..."
  16. c=0 ; zz="" ; do i=1 to logs ; zz=zz||logF.i" " ; end i
  17. do i=1 to words(a) ; se TWIRL()
  18.   if find(zz,word(a,i))=0 then do ; c=c+1 ; l.c=word(a,i) ; end
  19. end i
  20.  
  21. if c>0 then do
  22.   tr "n2New logs found:" ; do i=1 to c ; tr "   "l.i
  23.   call LOG("[N] Found and added the new log `"l.i"' to ViewLog5.") ; end i
  24.   se "n1Adding these logs to data files..."
  25.   call open(f1,comP"VL_Data2","r") ; z=readln(f1)
  26.     do i=1 until eof(f1) ; z.i=readln(f1) ; end i ; zz=i-1
  27.   call close(f1) ; call open(f1,comP"VL_Data2","w")
  28.     call writeln(f1,z+c) ; do i=1 to zz ; call writeln(f1,z.i) ; end i
  29.     do i=1 to c ; call writeln(f1,l.i) ; end i
  30.   call close(f1)
  31.   call open(f1,comP"VL_Titles","a")
  32.     do i=1 to c ; call writeln(f1,left(z+1,4)l.i) ; end i
  33.   call close(f1)
  34.   address command "SORT "comP"VL_Titles "comP"VL_Titles COLSTART 5"
  35.   do i=1 to c ; zz=logs+i
  36.     log.zz=left(z+i,4)left(l.i,15)left(l.i,15)left("31",15)left("31",90)
  37.     log.zz=log.zz||left(trim,2)left(trln,3)left(logH,2)left(hisT,4)
  38.     log.zz=log.zz||left("1",2)l.i ; end i ; logs=logs+c
  39.   call open(f1,comP"VL_Data","w") ; do i=1 to logs ; se TWIRL()
  40.     call writeln(f1,log.i) ; end i
  41.   call close(f1)
  42.   address command "SORT "comP"VL_Data "comP"VL_Data COLSTART 5"
  43.   tr "Done." ; signal BEGIN
  44. end
  45. else tr "No new logs found."
  46.  
  47. /* Trim ALL Logs */
  48.  
  49. tr "n1Trimming Logs...n1"
  50. do i=1 to logs
  51.   if ~exists("sysdata:log/"logF.i) | trim.i=1 then iterate i
  52.   se "Reading `"logN.i"' log...@4"
  53.   call open(f1,"sysdata:log/"logF.i,"r")
  54.     do j=1 until eof(f1) ; se TWIRL() ; l.j=readln(f1) ; end j ; l=j-1
  55.   call close(f1)
  56.   if l>trln.i then do ; se "trimming "l-trln.i" lines..."
  57.     call LOG("[A] Trimmed "l-trln.i" lines from the `"logN.i"' log file.")
  58.     call open(f1,"sysdata:log/"logF.i,"w")
  59.       do j=l-trln.i+1 to l ; se TWIRL() ; call writeln(f1,l.j) ; end j
  60.     call close(f1) ; end
  61.     if logH.i=1 & l>trln.i then do;se "appending to history..."
  62.       call LOG("[A] Appended "l-trln.i" lines to the `"logN.i"' log history.")
  63.       call open(f1,comP"Histories/"logF.i,substr("wa",exists(comP"Histories/"logF.i)+1,1))
  64.         do j=1 to l-trln.i ; se TWIRL() ; call writeln(f1,l.j) ; end j
  65.       call close(f1) ; end ; tr "Done!"
  66. end i
  67.  
  68. /* Trim ALL Histories */
  69.  
  70. tr "n1Trimming Histories...n1"
  71. do i=1 to logs
  72.   if ~exists(comP"Histories/"logF.i) | trim.i=1 | hisT.i=0 then iterate i
  73.   se "Reading `"logN.i"' history...@4"
  74.     call open(f1,comP"Histories/"logF.i,"r")
  75.       do j=1 until eof(f1) ; se TWIRL() ; l.j=readln(f1) ; end j ; l=j-1
  76.     call close(f1)
  77.     if l>hisT.i then do;se "trimming "l-hisT.i" lines..."
  78.       call LOG("[A] Trimmed "l-hisT.i" lines from the `"logN.i"' log history.")
  79.       call open(f1,comP"Histories/"logF.i,"w")
  80.         do j=l-hisT.i+1 to l ; se TWIRL() ; call writeln(f1,l.j) ; end j
  81.       call close(f1) ; end ; tr "Done!"
  82. end i
  83.  
  84. tr "n1ViewLog, v"ver" AutoMaintenance Completed!"
  85. call LOG("[*] View Log, v"ver" AutoMaintenance finished...")
  86. call MAKELOG ; exit
  87.  
  88. READCONFIG:;gu 1311992;comP=result
  89.   tr "f1cbViewLog, v"ver" AutoMaintenance...n1"
  90.   call open(f1,comP"ViewLog5.cfg","r")
  91.     vers=readln(f1) ; macc=readln(f1)
  92.     uacc=readln(f1) ; trim=readln(f1) ; trln=readln(f1)
  93.     logH=readln(f1) ; hisP=readln(f1) ; hisT=readln(f1)
  94.     ETex=readln(f1)
  95.     ARus=readln(f1);ARsy=readln(f1);ARpt=readln(f1)
  96.   call close(f1)
  97.  return
  98.  
  99. CHECKVER: ; if ver=vers then return
  100.   tr "f1n6c9Version Conflict:n1"
  101.   tr "   `ViewLog5.cfg' version: v"vers
  102.   tr "   `VL_AMaint'    version: v"ver
  103.   tr "n1   BOTH files above need to be v"max(ver,vers)"!"
  104.   tr "n1Halting, due to conflicting versions..."
  105.  exit
  106.  
  107. READDATA:
  108.   if ~exists(comP"VL_Data") then exit
  109.   call open(f1,comP"VL_Data","r") ; tw=0 ; se "Reading logs..."
  110.     do i=1 until eof(f1) ; log.i=readln(f1) ; se TWIRL()
  111.       parse var log.i 1 logI.i . 5 logN.i . 20 logF.i . 35 uacc.i .,
  112.                       50 uac.i"  " 138 trim.i . 140 trln.i . 143 logH.i .,
  113.                       145 hisT.i . 149 sysM.i . 151 asoc.i
  114.     end i ; logs=i-1 ; tr "Done!"
  115.   call close(f1)
  116.  return
  117.  
  118. TWIRL:;sh="--\\||//";tw=tw+1;if tw>8 then tw=1;return substr(sh,tw,1)"<1"
  119.  
  120. LOG:;parse arg text;zy=zy+1;text.zy="AUTO: ("date("u")" "time("c")")"text;return
  121. MAKELOG:;call open(f9,"SysData:Log/ViewLog5",substr("wa",exists("sysdata:log/viewlog5")+1,1))
  122.  do i=1 to zy;call writeln(f9,text.i);end i;call close(f9);return
  123.  
  124. exit
  125. SYNTAX:;ERROR:;IOERR:;e1=' Error: 'rc' ('errortext(rc)')'
  126.   e2='  Line: 'left(sigl,4)'File:';gu 1311992;a=result;gu 1311960
  127.   b=result;c='"'a||b'"';e2=e2' 'c;tr e1;tr e2;logentry e1;logentry e2
  128.   e=translate(sourceline(sigl),"\{","");do while e~=''
  129.   e3='Source: 'left(e,37);tr e3;logentry e3;e=substr(e,38);end;bufferflush
  130. /**************************************************************************\
  131. \****************************************** Frontiers BBS (716)/823-9892 **/
  132.